package com.cysion.study.ui

import com.cysion.other.color
import com.cysion.study.R
import com.cysion.study.helper.UserCache
import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.ktbox.utils.darkTextTheme
import com.cysion.study.net.ApiClient
import com.cysion.study.uibox.bar.TopBar
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.widget.ShowToast
import com.cysion.targetfun._subscribe
import kotlinx.android.synthetic.main.activity_cancelcourse_detail.*

class PCancelCourseDetailActivity :BaseActivity(){
    override fun getLayoutId(): Int {
        return R.layout.activity_cancelcourse_detail
    }

    private var id=""
    override fun initView() {
        id = intent.extras.getString("id")
        darkTextTheme(color(R.color.white))
        topbar.apply {
            setTitleBackColor(color(R.color.white))
            setTitle("消课详情")
            setOnTopBarClickListener { obj, pos ->
                if (pos == TopBar.Pos.LEFT) {
                    finish()
                }
            }
        }

    }
    override fun initData() {
        super.initData()
        getData()
    }
    private fun getData() {
        Alert.loading(self)
        ApiClient.api.getBalanceDetails(UserCache.token,id).compose(
            BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()

                    tv_money.text=it.celMoney
                    tv_name.text="学员姓名："+it.celStuNickName
                    tv_phone.text="联系方式："+it.celFamilyLink
                    tv_time.text="发起消课时间："+it.celStartTime
                    tv_num.text="课时数："+it.celCrsNum
                    tv_confirm.text="确认时间："+it.celEndTime

                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)
                }
            }
    }


    override fun closeMvp() {
    }

}
